package com.gsm.controller;

import com.gsm.entity.SubjectDetails;
import com.gsm.service.SubjectDetailsService;
import com.gsm.entity.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 科目介绍(SubjectDetails)表控制层
 *
 * @author wjq
 * @since 2020-04-26 23:00:34
 */
@RestController
@RequestMapping("subjectDetails")
public class SubjectDetailsController {
    @Autowired
    private SubjectDetailsService subjectDetailsService;
    
    /**
     * 新增
     */
    @PostMapping("subjectDetails")
    public Result insertSubjectDetails(@RequestBody SubjectDetails subjectDetails) {
        Result result = subjectDetailsService.insertSubjectDetails(subjectDetails);
        return result;
    }
    
    /**
     * 根据 id 删除数据
     */
    @DeleteMapping("subjectDetails/{subjectDetailsId}")
    public Result deleteSubjectDetailsBySubjectDetailsId(@PathVariable("subjectDetailsId")Long subjectDetailsId) {
        Result result = subjectDetailsService.deleteSubjectDetailsBySubjectDetailsId(subjectDetailsId);
        return result;
    }

    /**
     * 根据 id 修改单条数据
     */
    @PutMapping("subjectDetails/{subjectDetailsId}")
    public Result updateSubjectDetailsBySubjectDetailsId(@PathVariable("subjectDetailsId")Long subjectDetailsId, @RequestBody SubjectDetails subjectDetails) {
        subjectDetails.setSubjectDetailsId(subjectDetailsId);
        Result result = subjectDetailsService.updateSubjectDetailsBySubjectDetailsId(subjectDetails);
        return result;
    }

    /**
     * 根据 id 查询单条数据
     */
    @GetMapping("subjectDetails/{subjectDetailsId}")
    public Result selectSubjectDetailsBySubjectDetailsId(@PathVariable("subjectDetailsId")Long subjectDetailsId) {
        Result result = subjectDetailsService.selectSubjectDetailsBySubjectDetailsId(subjectDetailsId);
        return result;
    }

    /**
     * 根据 课程id 查询详细信息
     */
    @GetMapping("subjectDetails/subjectId/{subjectId}")
    public Result selectSubjectDetailsBySubjectId(@PathVariable("subjectId")Long subjectId) {
        Result result = subjectDetailsService.selectSubjectDetailsBySubjectId(subjectId);
        return result;
    }
    
    /**
     * 根据条件查询 List
     */
    @GetMapping("subjectDetailsList")
    public Result selectSubjectDetailsList(SubjectDetails subjectDetails) {
        Result result = subjectDetailsService.selectSubjectDetailsList(subjectDetails);
        return result;
    }
}